

import sys
import os
import zipfile

def do_zip_compress(dirname):
	output_name = f"{dirname}.zip"
	zip = zipfile.ZipFile(output_name, "w", zipfile.ZIP_DEFLATED)
	for root, dirs, files in os.walk(dirname):
		for file in files:
			zip.write(os.path.join(root, file))
	zip.close()


if __name__ == "__main__":
	dirname = sys.argv[1]
	if not os.path.isdir(dirname):
		raise Exception(f"这不是目录：{dirname}")

	do_zip_compress(dirname)
